#!/usr/bin/env node

//bmp  bit map 位图
const fs =require('fs');

const width = 16;
const height = 16;

const pixeIByteSize = width * height * 4;
const totalSize = pixeIByteSize + 54;

const buf = new Buffer(totalSize);
buf.fill(0);

//head
buf.write('BM');
buf.writeUInt32LE(totalSize,0x02);
buf.writeUInt32LE(54,0x0a);
buf.writeUInt32LE(40,0x0e);
buf.writeUInt32LE(1,0x1a);
buf.writeUInt32LE(32,0x1c);
buf.writeUInt32LE(pixeIByteSize,0x22);
buf.writeUInt32LE(width,0x12);
buf.writeUInt32LE(height,0x16);

//data
for(var i =54;i < totalSize;i+=4) {
    buf.writeUInt32LE(0xff0000ff, i);
}

fs.writeFile('./out.bmp', buf,function(err) {
    if(err != null) {
        console.error(err);
        process.exit(1);
    }
})


